package com.bz.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bz.common.Codeenum;
import com.bz.common.ResponseDto;
import com.bz.entity.ContactsEntity;
import com.bz.service.IContactsService;

@RestController
@RequestMapping(value = "/admin/contacts")
public class ContactsController {

    @Autowired
    private IContactsService contactsService;

    @RequestMapping(value = "/info")
    public ContactsEntity info() {
        return contactsService.get();
    }

    @RequestMapping(value = "/edit")
    public ResponseDto<String> add(@RequestBody @Valid ContactsEntity data) {
        contactsService.edit(data);
        return new ResponseDto<>(Codeenum.SUCCESS.getCode(), "添加成功");
    }
}
